package com.example.bookservice.dsl;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.example.bookservice.entity.Book;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86187
 * Date: 2023-10-21
 * Time: 21:27
 */
@Data
public class BookDSL {

    private static final long serialVersionUID = 1L;

    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long bookId;
    private String title;
    private String photo;
    private String author;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime publicationDate;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    private String category;
    private Boolean isApproved;
    private Boolean isAvailable;
    private Integer readeCount;
    private Double averageMark;

    private List<String> suggestion;

    public BookDSL(Book book) {
        this.bookId = book.getBookId();
        this.title = book.getTitle();
        this.photo = book.getPhoto();
        this.author = book.getAuthor();
        this.publicationDate = book.getPublicationDate();
        this.updateTime = book.getUpdateTime();
        this.category = book.getCategory();
        this.isApproved = book.getIsApproved();
        this.isAvailable = book.getIsAvailable();
        this.readeCount = book.getReadeCount();
        this.averageMark = book.getAverageMark();

        this.suggestion = Arrays.asList(this.author, this.title);
    }
}
